
package com.cari.baju.yog.helper;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.cari.baju.yog.entity.E_Toko;
import com.cari.baju.yog.utils.Utils;

public class JSONHelper {
    public static List<E_Toko> getToko(JSONArray arr) {
        List<E_Toko> listToko = new ArrayList<E_Toko>();
        for (int i = 0; i < arr.length(); i++) {
            try {
                JSONObject obj = arr.getJSONObject(i);

                listToko.add(new E_Toko(obj.getInt("id"),
                        obj.getInt("category"),
                        obj.getString("name"),
                        obj.getString("address"),
                        obj.getString("phone"),
                        obj.getDouble("lat"),
                        obj.getDouble("lng"),
                        obj.getInt("timestamp")));

            } catch (JSONException e) {
                Utils.TRACE("JSONHelper", "getToko : " + e.getMessage());
            }
        }
        return listToko;
    }
}
